package br.ucb.controller;

import java.io.Serializable;

import br.ucb.bean.Aluno;
import br.ucb.dao.AlunoDAO;
import br.ucb.util.SimpleEntityManager;

public class AlunoController extends GenericController implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private AlunoDAO alunoDAO;

	public AlunoDAO getAlunoDAO() {
		return alunoDAO;
	}

	public void setAlunoDAO(AlunoDAO alunoDAO) {
		this.alunoDAO = alunoDAO;
	}
	
	public void readyManagerAndDao() {
		setManager(new SimpleEntityManager("sacop"));
		this.alunoDAO = new AlunoDAO(getManager().getEntityManager());
		getManager().beginTransaction();
	}
	
	public boolean isAluno(Aluno aluno){
		readyManagerAndDao();
		Aluno temp = getAlunoDAO().buscarDuasColunas("nome", "matricula", aluno.getNome(), aluno.getMatricula());
		getManager().close();
		if(temp == null)
			return false;
		return true;
	}

}
